/*
 * Copyright 2011 Katsunori Koyanagi
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package sweezy.swf
{
	import flash.utils.ByteArray;
	import sweezy.swf.decoder.SWFDecoder;
	import sweezy.swf.encoder.SWFEncoder;
	import sweezy.swf.structure.Header;
	import sweezy.swf.structure.Structure;

	public class SWF extends Structure implements ISerializable
	{

		public static const RELEASE_BUILD:Boolean = !CONFIG::TEST;

		public static const VERSION:String = CONFIG::VERSION;

		public var header:Header;

		public var tags:Array;

		public function SWF()
		{
			super("SWF");
		}

		public function decode(bytes:ByteArray):void
		{
			var swf:SWF = new SWFDecoder().decode(bytes);
			header = swf.header;
			tags = swf.tags;
		}

		public function encode():ByteArray
		{
			return new SWFEncoder().encode(this);
		}
	}
}
